package is202.hrms.web;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 * Backing bean for innlogging. Den lagrer brukernavn og passord brukeren skriver inn,
 * og sjekker dette.
 * 
 * @author Anders
 */

@ManagedBean
@SessionScoped
public class Login {
       private String username;
       private String password;
        
       /**
        * Getter og setters
        */
        public String getUsername(){
            return username;
        }
        
        public void setUsername(String username){
            this.username = username;
        }
        
        public String getPassword(){
            return password;
        }
        
        public void setPassword(String password){
            this.password = password;
        }
        
        /**
         * Metoden som sjekker brukernavn og passord.
         */
        public String checkUser(){
            if(username.equals("student") && password.equals("student")){
                System.out.println("student");   
                
                                return "student";
            }
            else if(username.equals("foreleser") && password.equals("foreleser")){
                System.out.println("foreleser");
                
                                return "foreleser";
            }
            else{
                
                                return "fail";
            }
        }
    
}
